package cc.rengu.igas.momp.common.util;

import cc.rengu.igas.momp.common.enums.RespCodeEnum;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.utility.base.StringUtil;
import cc.rengu.utility.log.RgLogger;

/**
 * 公共报文检查
 *
 * @author Jinan Liu
 * @date 2020/5/20 08:55
 */
public class CommonMessageCheck {

    /**
     * 检查公共业务报文头数据是否为空
     *
     * @param queryType 查询类型
     * @param queryId   查询主体
     * @param queryRole 查询主体角色
     * @param rgLogger  日志
     * @throws BizException 异常信息
     * @author Jinan Liu
     * @date 2020/5/20 08:58
     */
    public static void checkBizMessageHeader(String queryType, String queryId, String queryRole, RgLogger rgLogger) throws BizException {

        if (StringUtil.isNullorEmpty(queryType) || StringUtil.isNullorEmpty(queryId) || StringUtil.isNullorEmpty(queryRole)) {
            rgLogger.error("公共业务数据不可为空!");
            throw new BizException(RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespCode(), RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespDesc());
        }
    }


    public static void checkSingleValue(String singleString, RgLogger rgLogger) throws BizException {

        if (StringUtil.isNullorEmpty(singleString)) {
            rgLogger.error("字段不可为空!");
            throw new BizException(RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespCode(), RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespDesc());
        }
    }

}
